﻿using System;
using ECSBase.Component.MaskRelated;

namespace ECSBase
{
    public class ECSWorld
    {
        public static EntityAdmin DefaultAdmin = new EntityAdmin();

        #region Entity-related

        public static Entity CreateEntity()
        {
            return DefaultAdmin.CreateEntity();
        }

        public static int AddEntity(Entity newEntity)
        {
            return DefaultAdmin.AddEntity(newEntity);
        }

        public static void DeleteEntity(int entityId)
        {
            DefaultAdmin.DeleteEntity(entityId);
        }

        public static Entity GetEntity(int entityId)
        {
            return DefaultAdmin.GetEntity(entityId);
        }

        public static Entity[] GetEntities(int Mask)
        {
            return DefaultAdmin.GetEntities(Mask);
        }

        public static T[] GetComponents<T>() where T : ComponentBase
        {
            return DefaultAdmin.GetComponents<T>();
        }

        public static void ClearEntity()
        {
            DefaultAdmin.ClearEntity();
        }

        #endregion

        #region SingletemComponent-related

        public static void AddSingletenComponent<T>() where T : ComponentBase
        {
            DefaultAdmin.AddSingletenComponent<T>();
        }

        public static T GetSingletenComponent<T>() where T : ComponentBase
        {
            return DefaultAdmin.GetSingletenComponent<T>();
        }

        public static void RemoveSingletenComponent<T>() where T : ComponentBase
        {
            DefaultAdmin.RemoveSingletenComponent<T>();
        }

        public static void ClearSingletenComponents()
        {
            DefaultAdmin.ClearSingletenComponents();
        }

        #endregion

        #region System-related

        public static T AddSystem<T>() where T : SystemBase
        {
            return DefaultAdmin.AddSystem<T>();
        }

        public static T GetSystem<T>() where T : SystemBase
        {
            return DefaultAdmin.GetSystem<T>();
        }

        public static void RemoveSystem<T>() where T : SystemBase
        {
            DefaultAdmin.RemoveSystem<T>();
        }

        public static void ClearSystem()
        {
            DefaultAdmin.ClearSystem();
        }

        #endregion

        #region Update related

        public static void UpdateOnce()
        {
            DefaultAdmin.UpdateOnce();
        }

        #endregion

        #region Mask-related

        public static MaskContainer DefaultMaskContainer = MaskDistributer.DefaultContainer;

        public static int GetMaskOfType(Type t)
        {
            return DefaultMaskContainer.GetMaskOfType(t);
        }

        public static int GetMaskOfTypes(params Type[] t)
        {
            return DefaultMaskContainer.GetMaskOfTypes(t);
        }

        #endregion
    }
}
